﻿#pragma once

#include "../../Server/MirEnvir/Envir.h"
#include "../../Server/MirDatabase/MapInfo.h"
#include "../../Server/MirDatabase/SafeZoneInfo.h"
#include "../../Server/MirDatabase/RespawnInfo.h"
#include "../../Server/MirDatabase/MovementInfo.h"
#include "../../Server/MirDatabase/MineInfo.h"
#include <string>
#include <vector>
#include <stdexcept>
#include <any>
#include "../../stringhelper.h"
#include "../../tangible_filesystem.h"

using namespace Server::MirDatabase;
using namespace Server::MirEnvir;


namespace Server
{
    class MapInfoForm : public System::Windows::Forms::Form
    {
    public:
        virtual ~MapInfoForm()
        {
            delete _info;
            delete components;
            delete MapTabs;
            delete tabPage3;
            delete RemoveSZButton;
            delete AddSZButton;
            delete SafeZoneInfoPanel;
            delete label12;
            delete SZYTextBox;
            delete label14;
            delete SizeTextBox;
            delete label17;
            delete SZXTextBox;
            delete StartPointCheckBox;
            delete SafeZoneInfoListBox;
            delete tabPage2;
            delete RPasteButton;
            delete RCopyButton;
            delete RemoveRButton;
            delete AddRButton;
            delete RespawnInfoListBox;
            delete RespawnInfoPanel;
            delete label24;
            delete DirectionTextBox;
            delete label8;
            delete DelayTextBox;
            delete label7;
            delete MonsterInfoComboBox;
            delete label6;
            delete SpreadTextBox;
            delete label9;
            delete RYTextBox;
            delete label10;
            delete CountTextBox;
            delete label13;
            delete RXTextBox;
            delete tabPage4;
            delete RemoveMButton;
            delete AddMButton;
            delete MovementInfoPanel;
            delete label22;
            delete DestMapComboBox;
            delete label18;
            delete DestYTextBox;
            delete label21;
            delete DestXTextBox;
            delete label16;
            delete SourceYTextBox;
            delete label20;
            delete SourceXTextBox;
            delete MovementInfoListBox;
            delete RemoveButton;
            delete AddButton;
            delete MapInfoListBox;
            delete PasteMapButton;
            delete CopyMapButton;
            delete tabPage1;
            delete label15;
            delete BigMapTextBox;
            delete LightsComboBox;
            delete label5;
            delete label1;
            delete label4;
            delete MapIndexTextBox;
            delete MiniMapTextBox;
            delete label2;
            delete MapNameTextBox;
            delete FileNameTextBox;
            delete label3;
            delete tabPage6;
            delete LightningCheckbox;
            delete FireCheckbox;
            delete FightCheckbox;
            delete NoReconnectCheckbox;
            delete NoTeleportCheckbox;
            delete LightningTextbox;
            delete FireTextbox;
            delete NoReconnectTextbox;
            delete NoNamesCheckbox;
            delete NoDropMonsterCheckbox;
            delete NoDropPlayerCheckbox;
            delete NoThrowItemCheckbox;
            delete NoPositionCheckbox;
            delete NoDrugCheckbox;
            delete NoRecallCheckbox;
            delete NoEscapeCheckbox;
            delete NoRandomCheckbox;
            delete NeedHoleMCheckBox;
            delete ImportMapInfoButton;
            delete ExportMapInfoButton;
            delete label19;
            delete MapDarkLighttextBox;
            delete tabPage7;
            delete MZDeletebutton;
            delete MZAddbutton;
            delete MineZonepanel;
            delete label30;
            delete MZYtextBox;
            delete label31;
            delete MZSizetextBox;
            delete label32;
            delete MZXtextBox;
            delete MZListlistBox;
            delete MineComboBox;
            delete MineZoneComboBox;
            delete label27;
            delete label33;
            delete ImportMongenButton;
            delete ExportMongenButton;
            delete VisualizerButton;
            delete NeedBridleCheckbox;
            delete NoMountCheckbox;
            delete label34;
            delete RoutePathTextBox;
            delete NoFightCheckbox;
            delete NeedMoveMCheckBox;
            delete label11;
            delete MusicTextBox;
            delete label23;
            delete Randomtextbox;
            delete toolTip1;
            delete chkrespawnsave;
            delete chkRespawnEnableTick;
            delete ConquestComboBox;
            delete label25;
            delete NoTownTeleportCheckbox;
            delete NoReincarnation;
        }

        Server::MirEnvir::Envir *getEnvir() const;

    private:
        std::vector<MapInfo*> _selectedMapInfos;
        std::vector<SafeZoneInfo*> _selectedSafeZoneInfos;
        std::vector<RespawnInfo*> _selectedRespawnInfos;
        std::vector<MovementInfo*> _selectedMovementInfos;
        std::vector<MineZone*> _selectedMineZones;
        MapInfo *_info;

    public:
        MapInfoForm();
    private:
        void MapInfoForm_FormClosed(std::any sender, FormClosedEventArgs *e);


        void UpdateInterface();
        void UpdateSafeZoneInterface();
        void UpdateRespawnInterface();
        void UpdateMovementInterface();

        void UpdateMineZoneInterface();

        void RefreshMapList();
        void RefreshSafeZoneList();
        void RefreshRespawnList();
        void RefreshMovementList();

        void RefreshMineZoneList();

        void AddButton_Click(std::any sender, EventArgs *e);
        void RemoveButton_Click(std::any sender, EventArgs *e);
        void MapInfoListBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void FileNameTextBox_TextChanged(std::any sender, EventArgs *e);
        void MapNameTextBox_TextChanged(std::any sender, EventArgs *e);
        void MiniMapTextBox_TextChanged(std::any sender, EventArgs *e);
        void LightsComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);


        void AddSZButton_Click(std::any sender, EventArgs *e);
        void RemoveSZButton_Click(std::any sender, EventArgs *e);
        void SafeZoneInfoListBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void SZXTextBox_TextChanged(std::any sender, EventArgs *e);
        void SZYTextBox_TextChanged(std::any sender, EventArgs *e);
        void SizeTextBox_TextChanged(std::any sender, EventArgs *e);
        void StartPointCheckBox_CheckedChanged(std::any sender, EventArgs *e);



        void AddRButton_Click(std::any sender, EventArgs *e);
        void RemoveRButton_Click(std::any sender, EventArgs *e);
        void RespawnInfoListBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void MonsterInfoComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void RXTextBox_TextChanged(std::any sender, EventArgs *e);
        void RYTextBox_TextChanged(std::any sender, EventArgs *e);
        void CountTextBox_TextChanged(std::any sender, EventArgs *e);
        void SpreadTextBox_TextChanged(std::any sender, EventArgs *e);
        void DelayTextBox_TextChanged(std::any sender, EventArgs *e);
        void DirectionTextBox_TextChanged(std::any sender, EventArgs *e);

        void RoutePathTextBox_TextChanged(std::any sender, EventArgs *e);

        void RPasteButton_Click(std::any sender, EventArgs *e);
        //RCopy




        void AddMButton_Click(std::any sender, EventArgs *e);
        void RemoveMButton_Click(std::any sender, EventArgs *e);
        void SourceXTextBox_TextChanged(std::any sender, EventArgs *e);
        void SourceYTextBox_TextChanged(std::any sender, EventArgs *e);
        void DestXTextBox_TextChanged(std::any sender, EventArgs *e);
        void DestYTextBox_TextChanged(std::any sender, EventArgs *e);
        void DestMapComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void NeedHoleMCheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void NeedScriptMCheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void MovementInfoListBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void PasteMapButton_Click(std::any sender, EventArgs *e);

        void BigMapTextBox_TextChanged(std::any sender, EventArgs *e);



        void NoTeleportCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoReconnectCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoReconnectTextbox_TextChanged(std::any sender, EventArgs *e);
        void NoRandomCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoEscapeCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoRecallCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoDrugCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoPositionCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoThrowItemCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoDropPlayerCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoDropMonsterCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void NoNamesCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void FightCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void FireCheckbox_CheckStateChanged(std::any sender, EventArgs *e);
        void FireTextbox_TextChanged(std::any sender, EventArgs *e);
        void LightningCheckbox_CheckedChanged(std::any sender, EventArgs *e);
        void LightningTextbox_TextChanged(std::any sender, EventArgs *e);

        void ClearHButton_Click(std::any sender, EventArgs *e);

        void MapDarkLighttextBox_TextChanged(std::any sender, EventArgs *e);

        void MZDeletebutton_Click(std::any sender, EventArgs *e);

        void MZAddbutton_Click(std::any sender, EventArgs *e);

        void MZListlistBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void MZMineIndextextBox_TextChanged(std::any sender, EventArgs *e);

        void MZXtextBox_TextChanged(std::any sender, EventArgs *e);

        void MZYtextBox_TextChanged(std::any sender, EventArgs *e);

        void MZSizetextBox_TextChanged(std::any sender, EventArgs *e);

        void ImportMapInfoButton_Click(std::any sender, EventArgs *e);
        void ExportMapInfoButton_Click(std::any sender, EventArgs *e);
        std::string PrintMapAttributes(MapInfo *map);
        void ImportMonGenButton_Click(std::any sender, EventArgs *e);
        void ExportMonGenButton_Click(std::any sender, EventArgs *e);

        void VisualizerButton_Click(std::any sender, EventArgs *e);

        void VForm_Disposed(std::any sender, EventArgs *e);

        void MineComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void MineZoneComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void NoMountCheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void NeedBridleCheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void NoFightCheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void MusicTextBox_TextChanged(std::any sender, EventArgs *e);

        void RandomTextBox_TextChanged(std::any sender, EventArgs *e);

        void chkRespawnEnableTick_CheckedChanged(std::any sender, EventArgs *e);

        void chkrespawnsave_CheckedChanged(std::any sender, EventArgs *e);

        void ConquestComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void NoTownTeleportCheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void NoReincarnation_CheckedChanged(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        TabControl *MapTabs;
        TabPage *tabPage3;
        Button *RemoveSZButton;
        Button *AddSZButton;
        Panel *SafeZoneInfoPanel;
        Label *label12;
        TextBox *SZYTextBox;
        Label *label14;
        TextBox *SizeTextBox;
        Label *label17;
        TextBox *SZXTextBox;
        CheckBox *StartPointCheckBox;
        ListBox *SafeZoneInfoListBox;
        TabPage *tabPage2;
        Button *RPasteButton;
        Button *RCopyButton;
        Button *RemoveRButton;
        Button *AddRButton;
        ListBox *RespawnInfoListBox;
        Panel *RespawnInfoPanel;
        Label *label24;
        TextBox *DirectionTextBox;
        Label *label8;
        TextBox *DelayTextBox;
        Label *label7;
        ComboBox *MonsterInfoComboBox;
        Label *label6;
        TextBox *SpreadTextBox;
        Label *label9;
        TextBox *RYTextBox;
        Label *label10;
        TextBox *CountTextBox;
        Label *label13;
        TextBox *RXTextBox;
        TabPage *tabPage4;
        Button *RemoveMButton;
        Button *AddMButton;
        Panel *MovementInfoPanel;
        Label *label22;
        ComboBox *DestMapComboBox;
        Label *label18;
        TextBox *DestYTextBox;
        Label *label21;
        TextBox *DestXTextBox;
        Label *label16;
        TextBox *SourceYTextBox;
        Label *label20;
        TextBox *SourceXTextBox;
        ListBox *MovementInfoListBox;
        Button *RemoveButton;
        Button *AddButton;
        ListBox *MapInfoListBox;
        Button *PasteMapButton;
        Button *CopyMapButton;
        TabPage *tabPage1;
        Label *label15;
        TextBox *BigMapTextBox;
        ComboBox *LightsComboBox;
        Label *label5;
        Label *label1;
        Label *label4;
        TextBox *MapIndexTextBox;
        TextBox *MiniMapTextBox;
        Label *label2;
        TextBox *MapNameTextBox;
        TextBox *FileNameTextBox;
        Label *label3;
        TabPage *tabPage6;
        CheckBox *LightningCheckbox;
        CheckBox *FireCheckbox;
        CheckBox *FightCheckbox;
        CheckBox *NoReconnectCheckbox;
        CheckBox *NoTeleportCheckbox;
        TextBox *LightningTextbox;
        TextBox *FireTextbox;
        TextBox *NoReconnectTextbox;
        CheckBox *NoNamesCheckbox;
        CheckBox *NoDropMonsterCheckbox;
        CheckBox *NoDropPlayerCheckbox;
        CheckBox *NoThrowItemCheckbox;
        CheckBox *NoPositionCheckbox;
        CheckBox *NoDrugCheckbox;
        CheckBox *NoRecallCheckbox;
        CheckBox *NoEscapeCheckbox;
        CheckBox *NoRandomCheckbox;
        CheckBox *NeedHoleMCheckBox;
        Button *ImportMapInfoButton;
        Button *ExportMapInfoButton;
        Label *label19;
        TextBox *MapDarkLighttextBox;
        TabPage *tabPage7;
        Button *MZDeletebutton;
        Button *MZAddbutton;
        Panel *MineZonepanel;
        Label *label30;
        TextBox *MZYtextBox;
        Label *label31;
        TextBox *MZSizetextBox;
        Label *label32;
        TextBox *MZXtextBox;
        ListBox *MZListlistBox;
        ComboBox *MineComboBox;
        ComboBox *MineZoneComboBox;
        Label *label27;
        Label *label33;
        Button *ImportMongenButton;
        Button *ExportMongenButton;
        Button *VisualizerButton;
        CheckBox *NeedBridleCheckbox;
        CheckBox *NoMountCheckbox;
        Label *label34;
        TextBox *RoutePathTextBox;
        CheckBox *NoFightCheckbox;
        CheckBox *NeedMoveMCheckBox;
        Label *label11;
        TextBox *MusicTextBox;
        Label *label23;
        TextBox *Randomtextbox;
        ToolTip *toolTip1;
        CheckBox *chkrespawnsave;
        CheckBox *chkRespawnEnableTick;
        ComboBox *ConquestComboBox;
        Label *label25;
        CheckBox *NoTownTeleportCheckbox;
        CheckBox *NoReincarnation;
    };
}
